<template>
  <view class="flex_page">
    <!-- <cl-nav-bar></cl-nav-bar> -->
    <web-view
      src="https://code-life-1302946402.cos.ap-chongqing.myqcloud.com/project/sjlm/i.html"
    />
  </view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app'

const title = ref('')
const htmlUrl = ref('')
onLoad((options = {}) => {
  const { type } = options
  console.log(type, 'type')
  if (type === 'agreement') {
    title.value = '用户协议'
  } else if (type === 'about') {
    title.value = '关于我们'
  } else if (type === 'complaint') {
    title.value = '投诉建议'
  }
  getHtmlData(type)
})

// 获取html文件
const getHtmlData = (contentFlag) => {
  uni
    .request({
      url: '/light-basic/wxUserLicenseController/list',
      data: {
        pageNum: 1,
        pageSize: -1,
        contentFlag,
      },
    })
    .then((data) => {
      const resData = data.reduce((prev, current) => {
        return prev.revNo > current.revNo ? prev : current
      })
      return Promise.resolve(resData)
    })
    .then((res) => {
      uni
        .request({
          url: '/light-basic/wxUserLicenseController/listFileUrlById',
          data: {
            id: res.id,
            field: 'fileId',
          },
        })
        .then((resData) => {
          if (resData.length > 0) {
            htmlUrl.value = resData[0].url
          }
        })
    })
}
</script>

<style lang="scss" scoped></style>
